name = str(input('请输入名字：'))
name += '.txt'
f1 = open(name)
str1=[]
a = str(input('请输入行数：'))
(x,y) = a.split(':')
print('\n文件名 %s 的从 %s 到%s 行的内容如下\n' % (name,x,y))
while True:
    if y != '末尾' and x != '开始':
        for i in f1:
            str1.append(i)
        for j in range(int(x)-1,int(y)):
            print(str1[j])
        break
    elif y == '末尾':
        if x != '开始':
            for i in f1:
                str1.append(i)
            lentgh = len(str1)
            for j in range(int(x)-1,lentgh):
                print(str1[j])
            break
        else:
            for i in f1:
                print(i)
    elif x == '开始':
        if y != '末尾':
            for i in f1:
                str1.append(i)
            for j in range(int(y)):
                print(str1[j])
            break
        else :
            for i in f1 :
                print(i)
